package com.ny.mapper;

import com.ny.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface USerMapper {
    @Select("select * from user")
    public List<User> findAllUser();

    @Select("select * from user where username=#{username} and password=#{password}")
    public User login(@Param("username") String username, @Param("password") String password);

    @Select("select * from user where username=#{username}")
    public User findUserByUsername(@Param("username") String username);

    @Insert("insert into user(username, password) values(#{username}, #{password})")
    public int insertUser(@Param("username") String username, @Param("password") String password);

    //验证邮箱存在
    @Select("select * from user where email= #{email}")
    public User fingUserByUsername(@Param("email") String email);

    // 查询邮箱号是否存在
    @Select("select * from user where email= #{email}")
    User findUserByEmail(String email);
}